package com.fourinone.utils;

import com.fourinone.SettingBean;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

/**
 * #created by outportMULLANG
 * #Wed Jan 31 11:53:24 CST 2007
 * YSJ=._me_ta.
 * YBB=._me_ta.version
 * YCJZ=._me_ta.createby
 * YCIP=._me_ta.creatip
 * YCSJ=._me_ta.creattime
 * YQX=._me_ta.auth
 * YSX=._me_ta.prop
 * YGXZ=._me_ta.updateby
 * YGIP=._me_ta.updateip
 * YGSJ=._me_ta.updatetime
 * SXXT=heartbeat
 * #PROTOCOL
 * QSXYSJ=sun.rmi.transport.tcp.responseTimeout
 * YMMZ=java.rmi.server.hostname
 * RZDY=java.rmi.server.logCalls
 * YCDYXY=rmi://
 * DMY=java.rmi.server.codebase
 * AQCL=java.security.policy
 * LSML=java.io.tmpdir
 * POLICY=grant{permission java.security.AllPermission;};
 * #APP
 * REQROOT=/
 * REQRES=/res
 * REQADMIN=/admin
 * REQFTTP=/admin/fttp.jsp
 * REQGETFTTP=/admin/getFttp.jsp
 * RSPE401=/WEB-INFO/err401.jsp
 * RSPFTTPJSP=/WEB-INFO/fttp.jsp
 * RSPFTTPJS=/WEB-INFO/fttp.js
 * RSPE404=/WEB-INFO/err404.jsp
 */
public class Setting {
    public static SettingBean sb = null;
    public static int corePoolSize = 10; //线程池初始
    public static int maximumPoolSize = 100; //最大线程
    public static long keepAliveTime = 3000; //存活时间
    public static long heartBeat = 3000;
    public static long maxDelay = 30000;
    //rmi时延、rmi hostname、日志、rmi请求头、编码基数、安全策略、认证、worker上的服务
    private static String QSXYSJ=null,YMMZ=null,RZDY=null,YCDYXY=null,DMY=null,AQCL=null,POLICY=null,LSML=null,SERVICEONWORKER=null;

    //public static TimeUnit unit = TimeUnit.MILLISECONDS; //顆粒度 毫秒

    /**
     * 生成SettingBean
     * @return
     */
    public static SettingBean getSettingBean() {
        return sb !=null?sb:new SettingBean("ISO-8859-1");
    }
    static String getQSXYSJ () {
        if (QSXYSJ == null) {
            QSXYSJ = getSettingBean().getString("QSXYSJ");
        }
        return QSXYSJ;
    }

    public static String getYMMZ() {
        if (YMMZ == null)
            YMMZ = getSettingBean().getString("YMMZ");
        return YMMZ;
    }

    public static String getRZDY() {
        if (RZDY == null)
            RZDY = getSettingBean().getString("RZDY");
        return RZDY;
    }

    public static String getYCDYXY() {
        if (YCDYXY == null)
            YCDYXY = getSettingBean().getString("YCDYXY");
        return YCDYXY;
    }

    public static String getDMY() {
        if (DMY == null) {
            DMY = getSettingBean().getString("DMY");
        }
        return DMY;
    }

    public static String getAQCL() {
        if (AQCL == null)
            AQCL = getSettingBean().getString("AQCL");
        return AQCL;
    }

    public static String getPOLICY() {
        if (POLICY == null)
            POLICY = getSettingBean().getString("POLICY");
        return POLICY;
    }

    public static String getLSML() {
        if (LSML == null) {
            LSML = getSettingBean().getString("LSML");
        }
        return LSML;
    }
    static String getProtocolInfo(String ym, int dk, String mc){
        return getYCDYXY()+ym+":"+dk+"/"+mc;
    }


    public static String getSERVICEONWORKER() {
        return SERVICEONWORKER;
    }
    public static String getProp (String keyWord) {
        return getSettingBean().getString(keyWord);
    }

    public static String getRequest(String requestUrl){
        return getSettingBean().getFileString(getSettingBean().getString(requestUrl));
    }
    public static void main(String args[]) {
        System.out.println(Setting.getDMY());
        //String response = Setting.getRequest(Setting.getProp("RSPE404"));
        //System.out.println(response);
    }
}
